package com.umeox.ota.data.constant;

import com.abupdate.iot_libs.data.constant.Error;
import com.umeox.ota.R;
import com.umeox.ota.gloable.App;

/**
 * @author fighter_lee
 * @date 2018/7/17
 */
public class Constant {

    /**
     * bind服务异常
     */
    public static final int BIND_SERVER_ERROR = 10001;

    public static final String SP_FOTA_INIT_COMPLETED = "sp_fota_init_completed";

    public static final int DEFAULT_MID_POLICY_EFFECTIVE_TIME = 7 * 24 * 60 * 60 * 1000;
    public static final int DEFAULT_MID_POLICY_EFFECTIVE_NUMBER = 50;
    public static final int MAX_DOWNLOAD_RETRY_TIME = 3;

    public static final String FLAVOR_DEVICE_TYPE_CAR = "Car";
    public static final String FLAVOR_DEVICE_TYPE_IOT = "Iot";
    public static final String FLAVOR_DEVICE_TYPE_BOX = "Box";
    public static final String FLAVOR_DEVICE_TYPE_SERVICE = "Service";

    public static final String SP_ACTIVITY_ORIENTATION = "sp_activity_orientation";

    public static final String INTERNAL_STORAGE_PATH = "/storage/emulated/0";

    public static final String OTA_PACKAGE_PATH = "/data/ota_package/update.zip";

    /**
     * =======================SP==============================
     */
    public static final String SP_ONLY_WIFI_DOWNLOAD = "sp_only_wifi_download";
    public static final String SP_OTA_SILENT_UPDATE = "sp_ota_silent_update";

    public static final int BINARY_INT = 1024;

    public static String getErrorMessage(int i) {
        switch (i) {
            case BIND_SERVER_ERROR:
                return "bind server occur error";
            default:
                return "UNKNOWN ERROR";
        }
    }

    public static String getDlTipByErrorCode(int error) {
        String tips = "";
        switch (error) {
            case Error.DOWNLOADING_MEMORY_NOT_ENOUGH:
                tips = App.sCx.getString(R.string.tips_download_memory_not_enough);
                break;
            case Error.DOWNLOADING_NOT_WIFI:
                tips = App.sCx.getString(R.string.tips_only_wifi_download);
                break;
            case Error.DOWNLOADING_INVALID_FILE:
                tips = App.sCx.getString(R.string.tips_upgrade_validate_file_fail);
                break;
            default:
                tips = App.sCx.getString(R.string.net_error_tips);
                break;
        }
        return tips;
    }

    public static String getUpdateTipByErrorCode(int error) {
        String tips = "";
        switch (error) {
            case Error.UPGRADE_BATTERY_NOT_ENOUGH:
                tips = App.sCx.getString(R.string.tips_battery_not_enough);
                break;
            case Error.UPGRADE_FILE_NOT_EXIST:
            case Error.UPGRADE_VALIDATE_FILE_FAIL:
            case Error.UPGRADE_IOEXCEPTION:
                tips = App.sCx.getString(R.string.tips_upgrade_validate_file_fail);
                break;
            case Error.DOWNLOADING_MEMORY_NOT_ENOUGH:
                tips = App.sCx.getString(R.string.tips_download_memory_not_enough);
                break;
            default:
                tips = App.sCx.getString(R.string.enter_recovery_fail);
                break;
        }
        return tips;
    }
}
